tools/oxenstored: Keep /dev/xen/evtchn open across live update
authorEdwin Török <edvin.torok@citrix.com>
Thu, 3 Nov 2022 15:31:39 +0000 (15:31 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 20 Dec 2022 13:13:40 +0000 (13:13 +0000)
commitf02171b663393e10d35123e5572c0f5b3e72c29d
tree23f42087d183c132292ecc2021ccc893f849292d
parent4b418768ef4d75d0f70e4ce7cb5710404527bf47
tools/oxenstored: Keep /dev/xen/evtchn open across live update

Closing the evtchn handle will unbind and free all local ports.  The new
xenstored would need to rebind all evtchns, which is work that we don't want
or need to be doing during the critical handover period.

However, it turns out that the Windows PV drivers also rebind their local port
too across suspend/resume, leaving (o)xenstored with a stale idea of the
remote port to use.  In this case, reusing the established connection is the
only robust option.

Therefore:
 * Have oxenstored open /dev/xen/evtchn without CLOEXEC at start of day.
 * Extend the handover information with the evtchn fd, domexc virq local port,
   and the local port number for each domain connection.
 * Have (the new) oxenstored recover the open handle using Xeneventchn.fdopen,
   and use the provided local ports rather than trying to rebind them.

When this new information isn't present (i.e. live updating from an oxenstored
prior to this change), the best-effort status quo will have to do.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
(cherry picked from commit 9b224c25293a53fcbe32da68052d861dda71a6f4)
tools/ocaml/xenstored/domain.ml
tools/ocaml/xenstored/domains.ml
tools/ocaml/xenstored/event.ml
tools/ocaml/xenstored/process.ml
tools/ocaml/xenstored/xenstored.ml